import { Redirect } from 'ice';
import store from '@/store';

const LoginWrapper = (WrappedComponent) => {
  const LoginWrappedPage = (props) => {
    const [user] = store.useModel('user');
    return <>{user.userInfo ? <WrappedComponent {...props} /> : <Redirect to="/login" />}</>;
  };

  return LoginWrappedPage;
};

export default LoginWrapper;
